﻿namespace Web.Control.WWW.Answers
{
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Text.RegularExpressions;
    using System.IO;
    using Lx.Web.Common.ControlsUI;
    using Lx.Web.Common.UI;
    using Model.WWW_WWW.Answers;
    using BLF.WWW_WWW.Answer;
    using System.Collections.Generic;
    using BLF;

    public class Categories : BaseControl
    {
        /// <summary>
        /// 目标语言
        /// </summary>
        protected string Learn = "";
        protected string BaseL = "";
        protected Repeater repPques;
        protected Repeater repLques;
        protected Repeater rptLL;
        protected Repeater rptOthLan;
        protected List<QuestionModel> pquesList;
        protected List<QuestionModel> lquesList;
        protected override void OnLoad(EventArgs e)
        {
            if (Request.Cookies["italkiLearn"] == null)
            {
                HttpCookie llCookie = new HttpCookie("italkiLearn", "");
                Response.Cookies.Add(llCookie);
            }
            if (Request.Cookies["italkiSpeak"] == null)
            {
                HttpCookie blCookie = new HttpCookie("italkiSpeak", "");
                Response.Cookies.Add(blCookie);
            }
            if (!string.IsNullOrEmpty(Request["ll"]) && Request["ll"] != "")
            {
                Learn = Request["ll"];
                HttpCookie llCookie = new HttpCookie("italkiLearn", Learn);
                Response.Cookies.Add(llCookie);
            }
            else
            {
                Learn = Request.Cookies["italkiLearn"].Value;
            }
            BaseL = Request.Cookies["italkiSpeak"].Value;
            pquesList = Answers.GetPuLa(Learn, out lquesList);
            if (repPques != null)
            {
                repPques.DataSource = pquesList;
                repPques.DataBind();
            }
            if (repLques != null)
            {
                repLques.DataSource = lquesList;
                repLques.DataBind();
            }

            if (rptLL != null)
            {
                List<LanguageObj> lanObjList = new List<LanguageObj>();
                lanObjList.AddRange(BLF.StaticData.GetPopLanguageList);
                rptLL.DataSource = lanObjList;
                rptLL.DataBind();
            }
            if (rptOthLan != null)
            {
                List<LanguageObj> lanObjList = new List<LanguageObj>();               
                lanObjList.AddRange(StaticData.GetLanguageObjList);
                for (; ; )
                {
                    if (lanObjList[0].LanguageValue.Trim() == "")
                    {
                        lanObjList.RemoveAt(0);
                        break;
                    }
                    else
                    {
                        lanObjList.RemoveAt(0);
                    }
                }                
                rptOthLan.DataSource = lanObjList;
                rptOthLan.DataBind();
            }
        }
       
    }
}


